﻿using System;
using System.Collections.Generic;
using System.Linq;
using System.Text;
using dllLink;
using System.Runtime.InteropServices;

namespace ConsoleProject
{
    static class Program
    {
        static void Main(string[] args)
        {
            Interface.test5();
            //Interface.testCalibTaux();
            Console.Write("fin");
            Console.Read();
        }

        /*
        //static private void test1()
        //{
        //    int myNbUnderlyings = 3;
        //    string[] myUnderlyingNames = new string[myNbUnderlyings];
        //    myUnderlyingNames[0] = "OPCVM1";
        //    myUnderlyingNames[1] = "OPCVM2";
        //    myUnderlyingNames[2] = "OPCVM3";
        //    int myNbFixingDates = 5;

        //    DateTime[] myFixingDates = new DateTime[myNbFixingDates];
        //    myFixingDates[0] = new DateTime(2003, 05, 02);
        //    myFixingDates[1] = new DateTime(2004, 05, 02);
        //    myFixingDates[2] = new DateTime(2005, 05, 02);
        //    myFixingDates[3] = new DateTime(2006, 05, 02);
        //    myFixingDates[4] = new DateTime(2007, 05, 02);
        //    Product myProduct = new Product(myUnderlyingNames, myFixingDates);

        //    Pricer myPricer = new Pricer(myProduct);


        //    DateTime myPricingDate = new DateTime(2009, 01, 11);
        //    //double[,] myNewScenario = myPricer.mScenarioGenerator(myPricingDate);
        //    //Console.WriteLine("-----" + myNewScenario[0, 0] + "-----");
        //}

        static private void test2()
        {
            int myNbUnderlyings = 3;
            string[] myUnderlyingNames = new string[myNbUnderlyings];
            myUnderlyingNames[0] = "OPCVM1";
            myUnderlyingNames[1] = "OPCVM2";
            myUnderlyingNames[2] = "OPCVM3";
            int myNbFixingDates = 5;

            DateTime[] myFixingDates = new DateTime[myNbFixingDates];
            myFixingDates[0] = new DateTime(2003, 05, 02);
            myFixingDates[1] = new DateTime(2004, 05, 02);
            myFixingDates[2] = new DateTime(2005, 05, 02);
            myFixingDates[3] = new DateTime(2006, 05, 02);
            myFixingDates[4] = new DateTime(2007, 05, 02);
            Product myProduct = new Product(myUnderlyingNames, myFixingDates);

            DateTime myPricingDate = new DateTime(2009, 01, 11);
            TimeSpan myHistoryDepth = new TimeSpan(260, 0, 0, 0);
            EstimatorMBG myEstimator = new EstimatorMBG(myProduct, myPricingDate, myHistoryDepth);
            double[] myReturns = myEstimator.mComputeReturn();
            double[,] myCovMatrix = myEstimator.mComputeMatCov();
            ModelMBG myModel = new ModelMBG();
            myModel.mSetParameters(myEstimator);

        }
        
        static private void test3()
        {
            
            GSLFunctions.initSeed();
            double test=0;
            double somme=0;
            double carre=0;
            int N = 1000;
            for (int i = 0; i < N; i++)
            {
                test = GSLFunctions.getGaussian();
                somme += test;
                carre += test * test;
            }
            Console.WriteLine("-- " + somme / N + " -- " + (carre / (N - 1) - (somme / N) * (somme / N)));
        }

        static private void test4()
        {
            Interface adaptater = new Interface();
            adaptater.connectBD();

            Console.WriteLine(" -- " + adaptater.dateMinCoteBD("OPCVM1"));
            adaptater.disconnectBD();
        }


        static private void test5()
        {
            int myNbUnderlyings = 10;
            string[] myUnderlyingNames = new string[myNbUnderlyings];
            myUnderlyingNames[0] = "OPCVM1";
            myUnderlyingNames[1] = "OPCVM2";
            myUnderlyingNames[2] = "OPCVM3";
            myUnderlyingNames[3] = "OPCVM4";
            myUnderlyingNames[4] = "OPCVM5";
            myUnderlyingNames[5] = "OPCVM6";
            myUnderlyingNames[6] = "OPCVM7";
            myUnderlyingNames[7] = "OPCVM8";
            myUnderlyingNames[8] = "OPCVM9";
            myUnderlyingNames[9] = "OPCVM10";
            int myNbFixingDates = 11;

            DateTime[] myFixingDates = new DateTime[myNbFixingDates];
            myFixingDates[0] = new DateTime(2002, 08, 07);
            myFixingDates[1] = new DateTime(2003, 08, 07);
            myFixingDates[2] = new DateTime(2004, 08, 09);
            myFixingDates[3] = new DateTime(2005, 08, 08);
            myFixingDates[4] = new DateTime(2006, 08, 07);
            myFixingDates[5] = new DateTime(2007, 08, 07);
            myFixingDates[6] = new DateTime(2008, 08, 07);
            myFixingDates[7] = new DateTime(2009, 08, 07);
            myFixingDates[8] = new DateTime(2010, 08, 09);
            myFixingDates[9] = new DateTime(2011, 08, 08);
            myFixingDates[10] = new DateTime(2012, 07, 30);
            Product myProduct = new Product(myUnderlyingNames, myFixingDates);

            DateTime myPricingDate = new DateTime(2009, 01, 11);
            TimeSpan myHistoryDepth = new TimeSpan(360, 0, 0, 0);

            Pricer myPricer = new Pricer(myProduct);
            TimeSpan myRebalancingPeriod = new TimeSpan(7, 0, 0, 0);
            ulong myNbDraws = 1000;
            GSLFunctions.initSeed();
            Double Price = myPricer.mPrice(myPricingDate, myRebalancingPeriod, myNbDraws, myHistoryDepth);
            Console.WriteLine(Price);
        */
        //}


    }
}
